/*
 * Copyright (C) 2016 The Fosafer Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.fosafer.idcard_demo.util;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.fosafer.idcard_demo.app.IDCardApp;

import java.io.InputStream;

/**
 * Create By :   IDEA
 * Package:      [com.fosafer.idcard_demo.util]
 * ClassName:    [ImageUtils]
 * Description:  [Image工具类]
 * Author:       [jianzhic]
 * CreateDate:   [16-4-12 15:05]
 * UpdateUser:   [jianzhic]
 * UpdateDate:   [16-5-12 15:05]
 * UpdateRemark: [Update Description]
 * Version:      [v1.0.0]
 * <p>
 * Copyright (c) 2016 Fosafer Co.,Ltd. All rights reserved.
 */
public class ImageUtils {


    /**
     * 以最省内存的方式读取本地资源的图片
     *
     * @param resId resID
     * @return Bitmap
     */
    public static Bitmap readBitMap(int resId) {
        BitmapFactory.Options opt = new BitmapFactory.Options();
        opt.inPreferredConfig = Bitmap.Config.RGB_565;
        opt.inPurgeable = true;
        opt.inInputShareable = true;
        //获取资源图片
        InputStream is = IDCardApp.getInstance().getResources().openRawResource(resId);
        return BitmapFactory.decodeStream(is, null, opt);
    }

}
